package com.lpw.dbvideo.video.dao;

import com.lpw.dbvideo.video.domain.Video;
import com.lpw.dbvideo.video.provider.VideoProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface VideoMapper {
    /**
     * 查询所有视频
     * @return
     */
    @Select("select * from video")
    List<Video> findAll();

    /**
     * 根据id查询视频
     * @param id
     * @return
     */
    @Select("select * from video where id = #{id}")
    Video findById(int id);

    /**
     * 根据id更新视频
     * @param video
     */
    //@Update("update video set title = #{title} where id = #{id}")
    @UpdateProvider(type = VideoProvider.class,method = "updateVideo")
    int update(Video video);

    /**
     * 根据id删除视频
     * @param id
     */
    @Delete("delete from video where id =#{id}")
    int delet(int id);

    /**
     * 新增视频
     * @param video
     * @return
     */
//    @Insert("insert into video (title,summary,cover_img,view_num,price,create_time,online,point) "
//            + "values "
//            + "(#{title},#{summary},#{coverImg},#{viewNum},#{price},#{createTime},#{online},#{point});")
    @InsertProvider(type = VideoProvider.class, method = "insertVideo")
    int save(Video video);
}